< previous page page_380 next page >

Page 380
the top of the world window. When the scrollbar value is 100, set the world window so that its top is at position 100, the picture's largest world coordinate. When the scrollbar's value is 10, set the world window so that its top is at position 10. This puts its bottom at position 1, so the world window displays the bottommost part of the picture.
In addition to Min and Max, you must set the scrollbars' SmallChange and LargeChange properties. SmallChange determines the amount by which a scrollbar's value changes when the user clicks on its arrow buttons. LargeChange determines the amount by which the value changes when the user clicks on the space between an arrow button and the thumb. Figure 12.8 shows the parts of a scrollbar where the user can click to cause a small or large change.
Set the SmallChange values so that the world window moves only a fraction of its own size across the picture when the user clicks on the arrows. Setting SmallChange to 10 or 20 percent of the size of the world window usually produces good results.
Set LargeChange to move the world window its current size across the picture when the user clicks between the arrows and the thumb. If the world window is 10 units tall, set LargeChange = 10. This not only lets the user move the picture a reasonable amount, but it also allows the scrollbar thumb to size itself proportionally. If the viewport displays half of the world window space, the scrollbar thumb occupies half of the scrollbar's area.
Scrollbars have two events that the program must handle. The Change event occurs when the value of the scrollbar has changed. This happens when the user clicks on the scrollbar to change its value or when the program explicitly sets the value of the scrollbar. Whenever the program receives a Change event, it should reposition the world window using the scrollbar's new value.
The second scrollbar event is the Scroll event. This occurs when the user has grabbed a scrollbar's thumb and is dragging it to a new position. As the user drags the thumb, Visual Basic may generate many Scroll events.
When the program receives Scroll events, it can reposition the world window using the scrollbar's new value. This makes the picture appear to move as the user is dragging the scrollbar's thumb. This produces a nice, smooth, interactive result.
If the picture is particularly time consuming to draw, however, the picture may seem to flicker. If the picture is extremely complicated, the picture may even repeatedly disappear and then slowly redraw as the user drags the thumb.
0380-01.jpg
Figure 12.8
The parts of a scrollbar.

 
< previous page page_380 next page >